package attack.snowman;

import org.newdawn.slick.Animation;
import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Rectangle;

import framework.BasicFighter;
import framework.Util;
import attack.nartan.SwordStrike;

public class CarrotStrike extends SwordStrike {

	public CarrotStrike(BasicFighter attacker) {
		super(attacker);
		Image[] frames = new Image[3];
		frames[0] = this.spriteSheet.getSprite(3, 1);
		frames[1] = this.spriteSheet.getSprite(1, 2);
		frames[2] = this.spriteSheet.getSprite(1, 2);
		this.attackAnimation = new Animation(frames, 150);
		this.attackAnimation.setDuration(0, 150);
		this.attackAnimationBackward = Util.getFlippedAnimation(this.attackAnimation, true, false);
		this.attacker = attacker;
		this.isJumpingAuthorized = false;
	}
	
	@Override
	public Rectangle getHitBox() {
		Rectangle hitBox, att;
		att = getAttacker().getHitBox();
		int width = (int) (att.getWidth() * 3);
		int y = (int) (att.getHeight() / 6);
		if(attackAnimationUsed == attackAnimation) {
			hitBox = new Rectangle(att.getX() +  att.getWidth(), att.getY() +  y, 
					               width, att.getHeight() / 4);
		} else {
			hitBox = new Rectangle(att.getX() - width, att.getY() +  y, 
					               width, att.getHeight() / 4);
		}
		return attackAnimation.getFrame() == 1 || attackAnimationBackward.getFrame() == 1 ? 
				hitBox : new Rectangle(-1000, -1000, 0, 0);
	}
}
